classdef SimpleMeasurement < MeasurementSession.AbstractMeasurementSession
    %SIMPLEMEASUREMENT �˴���ʾ�йش����ժҪ
    %   �˴���ʾ��ϸ˵��
    
    properties
    end
    
    methods
        function obj = SimpleMeasurement(varargin)
            p=inputParser;

            isGroupMember = @(x) ismember(x, Constant.GroupMember);
            
            p.addParameter('owner', 'ZN', isGroupMember);
            p.addParameter('name', 'Simple', @ischar);
            p.addParameter('device_file', [Constant.AutoMeasurementCorePath '\+MeasurementSession\@SimpleMeasurement\DefaultDevice.dat'], @ischar);
            p.addParameter('isInitialize', true, @islogical);
            p.parse(varargin{:});
            
            device_file = p.Results.device_file;
            isInit = p.Results.isInitialize;
            

            obj@MeasurementSession.AbstractMeasurementSession(p.Results.name);
            obj.session_owner = p.Results.owner;
            
            if isInit
                obj.initialize_session(device_file);
            end
        end

        %% save and load
        function s = saveobj(obj)
            s.session_name = obj.session_name;
            s.repository_revision = obj.repository_revision;
            s.repository_status = obj.repository_status;
            s.start_time = obj.start_time;
            s.finish_time = obj.finish_time;
            s.device_file = obj.device_file;
            s.control_parameter = obj.control_parameter;
            s.loop_parameter = obj.loop_parameter;
            s.measurement_data = obj.measurement_data;
            s.session_description = obj.session_description;
            s.session_owner = obj.session_owner;
        end
        
    end
    
    methods (Static)
       function obj = loadobj(s)
          if isstruct(s)
             newObj = MeasurementSession.SimpleMeasurement('owner', s.session_owner, 'device_file', s.device_file, 'isInitialize', false); 
             newObj.session_name = s.session_name;
             newObj.repository_revision = s.repository_revision;
             newObj.repository_status = s.repository_status;
             newObj.device_file = s.device_file;
             newObj.start_time = s.start_time;
             newObj.finish_time = s.finish_time;
             newObj.control_parameter = s.control_parameter;
             newObj.loop_parameter = s.loop_parameter;
             newObj.measurement_data = s.measurement_data;
             newObj.session_description = s.session_description;
             obj = newObj;
          else
             obj = s;
          end
       end
    end
    
    methods
        run(obj)
        post_process(obj)
    end
end

